var serverIp = "http://180.209.98.88:8101";

$(function(){

    // 动态计算新闻列表文字样式
    auto_resize();
    $(window).resize(function() {
        auto_resize();
    });
    $('.am-list-thumb img').load(function(){
        auto_resize();
    });

    $('.am-list > li:last-child').css('border','none');
    function auto_resize(){
        $('.pet_list_one_nr').height($('.pet_list_one_img').height());

    }
    $('.pet_nav_gengduo').on('click',function(){
        $('.pet_more_list').addClass('pet_more_list_show');
    });
    $('.pet_more_close').on('click',function(){
        $('.pet_more_list').removeClass('pet_more_list_show');
    });
});

function refresh(num) {
    $.ajax({
        type: "GET",
        url: serverIp + "/tags/list.do",
        data: {num: num},
        contentType: 'application/json',
        dataType: 'json',
        success: function (result) {
            $.each(result.data, function (i, item) {
                var status = item.status;
                if (status === 1) {
                    var id = item.id;
                    var title = item.title;
                    var abstract = item.tagAbstract;
                    var url = item.externalUrl;
                    var pUrl = item.pictureUrl;
                    console.log("id为"+id+"  标签的"+"标题为"+title+ "  概要为："+abstract+ "  外部链接为"+url+ " 图片的链接为" + pUrl);

                    $("#tag_list").append(
                        "<li class=\"am-g am-list-item-desced am-list-item-thumbed am-list-item-thumb-right pet_list_one_block\">" +
                        "<div class=\"pet_list_one_info\">" +
                        "<div class=\"pet_list_one_info_l\">" +
                        "<div class=\"pet_list_one_info_ico\"><img src=\"img/yiban-banner.png\" alt=\"\"></div>" +
                        "<div class=\"pet_list_one_info_name\">大易</div>\n" +
                        "</div>" +
                        "</div>" +
                        "<div class=\" am-u-sm-8 am-list-main pet_list_one_nr\">\n" +
                        "<h3 class=\"am-list-item-hd pet_list_one_bt\"><a href=\""+url+"\" class=\"\">"+title+"</a></h3>" +
                        "<div class=\"am-list-item-text pet_list_one_text\">"+abstract+"</div>" +
                        "</div>" +
                        "<div class=\"am-u-sm-4 am-list-thumb\">" +
                        "<a href=\"###\" class=\"\">\n" +
                        "<img src=\""+pUrl+"\" class=\"pet_list_one_img\" alt=\"\"/>" +
                        "</a>" +
                        "</div>"+
                        "</li>"
                    )
                }
            })
        },
        error: function (request, errorType, errorMessage) {
            alert("请求数据失败");
        }
    })
}

refresh(10);